﻿using GalaSoft.MvvmLight;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;

namespace DSParaView
{
    /// <summary>
    /// CtrlSlotItem.xaml 的交互逻辑
    /// </summary>
    public partial class CtrlSlotItem : UserControl
    {
        private CtrlSlotItemModel vm = new CtrlSlotItemModel();

        public CtrlSlotItem()
        {
            InitializeComponent();
        }

        private void BtnClick_ReSet(object sender, RoutedEventArgs e)
        {
            vm = this.DataContext as CtrlSlotItemModel;
            if (vm == null)
                return;
            for (int i = 0; i < vm.ListSlots.Count; i++)
            {
                vm.ListSlots[i].ToSlot = vm.ListSlots[i].FromSlot;
            }
        }
    }

    public class CtrlSlotItemModel : ViewModelBase
    {
        private ObservableCollection<OneSlotModel> _ListSlots = new ObservableCollection<OneSlotModel>();
        public ObservableCollection<OneSlotModel> ListSlots { get { return _ListSlots; } set { Set("ListSlots", ref _ListSlots, value); } }
    }

    public class OneSlotModel : ViewModelBase
    {
        private int _FromSlot;
        public int FromSlot { get => _FromSlot; set => Set("FromSlot", ref _FromSlot, value); }

        private int _ToSlot;
        public int ToSlot { get => _ToSlot; set => Set("ToSlot", ref _ToSlot, value); }
    }
}